{include file="public/header" /}
<body>
<div class="layui-fluid layui-anim-fadein">
	<div class="layui-card">
		<div class="layui-card-body">
			<form class="layui-form layui-form-pane" id="form" action='{:url("role/give",["id"=>$Request.param.id])}'>
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label"> 拥有权限 </label>
					<table class="layui-table layui-input-block">
						<tbody>
						{volist name="list" id="vo"}
						<tr>
							<td width="120">
								<input type="checkbox" name="rules[]" value="{$vo.id}" title="{$vo.title}" {if $vo.checked=="1"}checked{/if} lay-filter="nav1" lay-skin="primary"/>
							</td>
							<td>
								<div class="layui-input-block">
									{volist name="$vo.child" id="son"}
									<input type="checkbox" name="rules[]" {if $son.checked=="1"}checked{/if} value="{$son.id}" title="{$son.title}" parent="{$vo.id}" lay-filter="nav2" lay-skin="primary" />
									{/volist}
								</div>
							</td>
						</tr>
						{/volist}
						</tbody>
					</table>
				</div>
			</form>
		</div>
		{include file="public/submit" /}
	</div>
</div>

{include file="public/footer" /}
<script>
	layui.use(['form', 'layer'], function(){
		$ = layui.jquery;
		var form = layui.form, layer = layui.layer;

		//点击一级权限
		form.on('checkbox(nav1)',function(data){
			var obj = $(data.elem);
			$('[lay-filter=nav2][parent='+obj.val()+']').prop('checked',obj.prop('checked'));
			form.render('checkbox');
		})
	});
</script>
</body></html>